<?php  
        session_start();
        require('../Model/mysql.php');
        require('../host_config.php');
		if (!isset($_SESSION['shopid']) && isset($_SESSION['flag'])) {
            echo "<script language='javascript'>";
            echo "alert('You have no permission to read this page!');";
            echo "history.back();";
            echo "</script>";
            header("location:../login.php");
       	}else if($_SESSION['flag'] == "2") {
   
		}else if($_SESSION['shopid'] != $_GET['id']) {
        	header("location:test.php?id=".$_SESSION['shopid']);
        }
        	$shopid = $_GET['id'];
        
        $mysql = new MySQL();
        $link = $mysql->connect($mysql_host, $mysql_user, $mysql_passwd, $mysql_db);
        $shopid = mysql_real_escape_string($shopid);
        header("refresh:10");
		$sql = "SELECT `fullname`, `maxofnumber`,`currentnumber` FROM `Shops` WHERE `shopid` = '$shopid'";
		$str = $mysql->query_row($sql, $link);
		$fullname = $str[0];
		$maxofnumber = $str[1];
		$currentnumber = $str[2];
		if($maxofnumber - $currentnumber < 0) {
			$num = 0;
		}else {
			$num = $maxofnumber - $currentnumber;
		}
		/*
		$sql = "SELECT id FROM login_user WHERE all_name = '$str[0]'";
		$str2 = $mysql->query_row($sql, $link);
		$u_id = $str2[0];
		*/
?>
<!DOCTYPE html>
<html>
<head>
	<meta name="viewport" content="width=device-width; text/html; charset=utf-8" http-equiv="Content-Type">
	<title>登入系統</title>
	<link href="../mobile.css" rel="stylesheet" type="text/css">
</head>
<body>
	<div id="banner">查詢結果
		<div id="home">	
			<a href="select.php?id=<?php echo $shopid;?>">
			<img alt="" class="auto-style1" height="40" src="../pic/home.png" width="40"></a>
		</div>
		<div id="logout">
			<a href="../logout.php">
			<img alt="" class="auto-style1" height="41" src="../pic/logout.png" width="41"></a>
		</div>
	</div>
	<div id="content">
		<br/>
		<p>餐廳：<?php echo $fullname;?></p>
		<p>可供訂位人數：<?php echo $maxofnumber;?></p>
		<p>剩餘訂位人數：<?php echo $num;?></p>
		<p>
			&nbsp;<a href="store_main.php?id=<?php echo $shopid;?>">店家訂位</a>
			&nbsp;<a href="client.php?id=<?php echo $shopid;?>">訂位資訊</a>
		</p>
		<hr>
		<br/>
	</div>
</body>
</html>
